const router = require('koa-router')()
const Mock = require('mockjs')

const { list } = Mock.mock({
    'list|1000': [{
      "id|+1": 1,
      title: '@ctitle',
      'image': '@image("200x100", "@color, "@color", "Hello Koa")',
      desc: "@cword(10, 20)"
    }]
})


router.get('/list', ctx => {
  const { pageSize = 20, pageCode = 1 } = ctx.request.query;
  const result = list.slice((pageCode - 1) * pageSize, pageCode * pageSize)
  ctx.body = {
    code: 200,
    data: result
  }
})

module.exports = router
